import 'package:flutter/material.dart';

import './push_b.dart';

class PushA extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('过渡动画页面A'),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            RaisedButton(
              onPressed: () {
                Navigator.of(context).push(PageRouteBuilder(
                  transitionDuration: Duration(seconds: 1),
                  pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
                    return ScaleTransition(
                      scale: animation,
                      child: PushB(),
                    );
                  },
                ));
              },
              child: Text('Scale方式跳转'),
            ),

            RaisedButton(
              onPressed: () {
                Navigator.of(context).push(PageRouteBuilder(
                  transitionDuration: Duration(seconds: 1),
                  pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
                    return FadeTransition(
                      opacity: animation,
                      child: PushB(),
                    );
                  },
                ));
              },
              child: Text('Fade方式跳转'),
            ),

            RaisedButton(
              onPressed: () {
                Navigator.of(context).push(PageRouteBuilder(
                  transitionDuration: Duration(seconds: 1),
                  pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
                    return SizeTransition(
                      sizeFactor: animation,
                      child: PushB(),
                    );
                  },
                ));
              },
              child: Text('Size方式跳转'),
            ),

            RaisedButton(
              onPressed: () {
                Navigator.of(context).push(PageRouteBuilder(
                  transitionDuration: Duration(seconds: 1),
                  pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
                    return RotationTransition(
                      turns: animation,
                      child: PushB(),
                    );
                  },
                ));
              },
              child: Text('Rotation方式跳转'),
            ),

          ].map((e) {
            return Padding(
              padding: EdgeInsets.all(16),
              child: e,
            );
          }).toList(),
        ),
      ),
    );
  }
}